'''
Created on Sep 25, 2012

@author: etibar
'''
import json
import urllib, urllib2
from urlparse import urlparse 
import simplejson
import httplib2 as http


def connect_mirror(usr_name, usr_pwd):
    uname = usr_name
    pword = usr_pwd
    body = '{"F":"de.idgard.webapp.user.client.service.LoginServiceRF","I":[{"O":"tuoj6$BdN$1Dl36xnVmwQgKUkt4=","P":['+uname+','+pword+',"Erforderlicher Passcode for Login:",null,"kElVT0ZmTLGFfe-xsI6q"]}]}'
    headers = {
    'Content-Type' : 'application/json; charset=UTF-8',
    }
    uri = 'https://mirror.itsmyprivacy.de'
    path = '/login/service'
    target = urlparse(uri+path)
    h = http.Http()
    response = h.request(
            uri = target.geturl(),
            method ="POST",
            headers = headers,
            body = body)
    print (headers, body)
    print response


if __name__ == '__main__':
#    connect_idgard()
#    test_connection_new()
    pass